#include <iostream>
#include <vector>
using namespace std;

void insertSort(vector<int>& res){
	int len = res.size();
	for(int i = 1;i < len ;i++){
		int tmp = res[i];
		int j = 0;
		for(j = i - 1 ; j >= 0 ; j--){
			if(res[j] > tmp ){
				res[j + 1] = res[j];
				continue;
			}
			break;
		}
		res[j + 1] = tmp;
	}
}

int main(){
	int arr[] = {3,4,1,5,8,6,9};
	vector<int> res(arr,arr + 7);
	insertSort(res);
	vector<int>::iterator ite = res.begin();
	for(;ite != res.end(); ite++){
		cout<<*ite<<" ";
	} 
	system("pause");
	return 0;
}
